#ifndef CATALOG_H
#define CATALOG_H

#include <string>
#include <vector>
#include <unordered_map>
#include <memory>

struct ColumnInfo {
    std::string name;
    std::string type;
    int length;
};

struct TableInfo {
    std::string name;
    std::vector<ColumnInfo> columns;
    uint32_t firstPageId;
};

class BufferPool;

class Catalog {
public:
    Catalog(std::unique_ptr<BufferPool> bufferPool);
    ~Catalog();

    bool createTable(const TableInfo& tableInfo);
    bool dropTable(const std::string& tableName);
    TableInfo* getTable(const std::string& tableName);
    std::vector<TableInfo> getAllTables();

    bool loadFromStorage();
    bool saveToStorage();
    
    // Get BufferPool pointer
    std::unique_ptr<BufferPool>& getBufferPool();

private:
    std::unordered_map<std::string, TableInfo> tables;
    std::unique_ptr<BufferPool> bufferPool;
};

#endif // CATALOG_H
